﻿using System;
using UnityEngine;

// Token: 0x02000143 RID: 323
[DisallowMultipleComponent]
[RequireComponent(typeof(Renderer))]
[AddComponentMenu("RVP/C#/Damage/Shatter Part", 2)]
public class ShatterPart : MonoBehaviour
{
	// Token: 0x060005D9 RID: 1497 RVA: 0x0002E797 File Offset: 0x0002C997
	private void Start()
	{
		this.rend = base.GetComponent<Renderer>();
		if (this.rend)
		{
			this.initialMat = this.rend.sharedMaterial;
		}
	}

	// Token: 0x060005DA RID: 1498 RVA: 0x0002E7C8 File Offset: 0x0002C9C8
	public void Shatter()
	{
		if (!this.shattered)
		{
			this.shattered = true;
			if (this.shatterParticles)
			{
				this.shatterParticles.Play();
			}
			if (this.brokenMaterial)
			{
				this.rend.sharedMaterial = this.brokenMaterial;
			}
			else
			{
				this.rend.enabled = false;
			}
			if (this.shatterSnd)
			{
				this.shatterSnd.Play();
			}
		}
	}

	// Token: 0x0400089C RID: 2204
	[NonSerialized]
	public Renderer rend;

	// Token: 0x0400089D RID: 2205
	[NonSerialized]
	public bool shattered;

	// Token: 0x0400089E RID: 2206
	public float breakForce = 5f;

	// Token: 0x0400089F RID: 2207
	[Tooltip("Transform used for maintaining seams when deformed after shattering")]
	public Transform seamKeeper;

	// Token: 0x040008A0 RID: 2208
	[NonSerialized]
	public Material initialMat;

	// Token: 0x040008A1 RID: 2209
	public Material brokenMaterial;

	// Token: 0x040008A2 RID: 2210
	public ParticleSystem shatterParticles;

	// Token: 0x040008A3 RID: 2211
	public AudioSource shatterSnd;
}
